<?php
class AppManager
{
	public function getNewKey() {
		$result = -1;
		$sql="delete from key_table";
		mysql_query($sql);
		$val = rand ( 20000 ,60000 );
		$sql="insert into key_table (key_field) values($val) ";
		mysql_query($sql);
	  return $this->getKey();
	}
	
	public function getKey() {
		$sql="select key_field from key_table";
    $q = mysql_query($sql);
    while($row = mysql_fetch_assoc($q))
    {
    	$result = $row["key_field"];
    }
		
    return $result;
	}
	
	
	
	
}
?>